package com.qianfeng.openapi.managerplateform.controlller;

import com.qianfeng.openapi.managerplateform.dao.AppInfoDao;
import com.qianfeng.openapi.managerplateform.pojo.AppInfo;
import com.qianfeng.openapi.managerplateform.pojo.ResponseData;
import com.qianfeng.openapi.managerplateform.service.AppInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/sys/app_info")
public class ApplyController {
    ///sys/app_info/table----应用查看所有  getAllApply
    @Autowired
    private AppInfoService appInfoService;
    ResponseData responseData = new ResponseData();
    @RequestMapping("/table")
    public ResponseData getAllAppInfo(int page,int limit){

        return appInfoService.getAllAppInfo(page, limit);
    }


    // /sys/app_info/add
    @RequestMapping("/add")
    public ResponseData addAppInfo(AppInfo appInfo){

        boolean b = appInfoService.addAppInfo(appInfo);
        if(b){
            responseData.setCode(1);
            responseData.setMsg("true");
            responseData.setData(b);
            return responseData;
        }else {
            responseData.setCode(0);
            responseData.setMsg("false");
            return responseData;
        }
    }
//sys/app_info/del
    @RequestMapping("/del")
    public ResponseData delAppInfo(int[] ids){
       return  appInfoService.delAppInfo(ids);
    }

    @RequestMapping("/update")
    public ResponseData updateAppInfo(AppInfo appInfo){
        boolean b = appInfoService.updateAllInfo(appInfo);
        if(b){
            responseData.setCode(1);
            responseData.setMsg("true");
            responseData.setData(b);
            return responseData;
        }
        responseData.setCode(0);
        responseData.setMsg("false");
        return responseData;
    }

}
